<?php
/**
 * Created by PhpStorm.
 * User: kb112
 * Date: 2016/12/12
 * Time: 14:58
 */

namespace soa\express\express;


class status
{
    /**
     * @var array
     */
    private static $status_map = [
        'ready' => [0, '待发货'],
        'collected' => [1, '已揽件'],
        'sending' => [2, '运输中'],
        'delivering' => [3, '派送中'],
        'question' => [4, '问题件'],
        'deposited' => [5, '代收中'],
        'signed' => [6, '已签收'],
//        'retention' => '滞留件',
//        'arrived' => '已到达',

    ];

    /**
     * 比较状态
     * @param $status1
     * @param $status2
     * @return bool
     */
    public static function compareStatus($status1, $status2)
    {
        if (isset(self::$status_map[$status1]) && isset(self::$status_map[$status2])) {
            return self::$status_map[$status1][0] - self::$status_map[$status2][0];
        }
        return false;
    }

    /**
     * 获取状态
     * @param $status
     * @return mixed|string
     */
    public static function getStatus($status)
    {
        $status = isset(self::$status_map[$status]) ? self::$status_map[$status][1] : '未知';

        return $status;
    }

    /**
     * 获取状态数值, 用于比较
     * @param $status
     * @return int
     */
    public static function getStatusNum($status)
    {
        $status = isset(self::$status_map[$status]) ? self::$status_map[$status][0] : -1;

        return $status;
    }
}